<template>
    <div class="e-form">
        <BillTop title="大修计划变更详情" @cancel="handleClose"></BillTop>
        <div class="tabs warningTabs">
            <el-tabs tab-position="left" v-model="tabsName" @tab-click="onChangeTab">
                <!-- 基本信息 -->
                <el-tab-pane label="基本信息" name="baseInfo" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="计划明细" name="planDetail" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="附件信息" name="attach" :disabled="clickTabFlag"></el-tab-pane>
                <el-tab-pane label="审核历史" name="auditHistory" :disabled="clickTabFlag"></el-tab-pane>
                <div>
                    <div id="baseInfoCon" class="con">
                        <div class="tabs-title" id="baseInfo">基本信息</div>
                        <div style="width: 100%" class="form">
                            <el-form ref="form" :model="formData.planRepair" label-width="200px">
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="计划编号：">
                                            <span>{{ formData.planRepair.billNo }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="变更编号：">
                                            <span>{{ formData.planRepair.changeBillNo }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="变更日期：">
                                            <span>{{ formData.planRepair.billDate }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="变更期数：">
                                            <span>{{ formData.planRepair.number }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="原计划维修费（元）：">
                                            <span>{{ formData.planRepair.budgetAmount }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="变更后计划维修费（元）：">
                                            <span>{{ formData.planRepair.changeBudgetAmount }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-col :span="12">
                                        <el-form-item label="机构：">
                                            <span>{{ formData.planRepair.orgName }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="状态：">
                                            <span>{{ statusLable(formData.planRepair.state) }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row>
                                    <el-form-item  label="备注：">
                                        <span>{{formData.planRepair.remarks}}</span>
                                    </el-form-item>
                                </el-row>
                                <el-row v-if="formData.planRepair.state === 5">
                                        <el-col :span="12">
                                        <el-form-item label="作废人：">
                                            <span>{{ formData.planRepair.nullifyCreator }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="作废原因：">
                                            <span>{{formData.planRepair.nullifyReason }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                                <el-row v-if="formData.planRepair.state === 5">
                                    <el-col :span="12">
                                        <el-form-item label="作废说明：">
                                            <span>{{
                                                formData.planRepair.nullifyDescription
                                            }}</span>
                                        </el-form-item>
                                    </el-col>
                                    <el-col :span="12">
                                        <el-form-item label="作废时间：">
                                            <span>{{
                                                formData.planRepair.nullifyCreated
                                            }}</span>
                                        </el-form-item>
                                    </el-col>
                                </el-row>
                            </el-form>
                        </div>
                    </div>

                    <div id="planDetailCon">
                        <div class="tabs-title" id="planDetail">计划明细</div>
                        <div class="e-table">
                            <div class="top">
                                <div class="left"></div>
                                <div class="right">
                                    <div class="squarecolor">
                                        <div class="color colorAdd"></div>
                                        <span>新增</span>
                                    </div>
                                    <div class="squarecolor item">
                                        <div class="color colorUpdate"></div>
                                        <span>修改</span>
                                    </div>
                                    <div class="squarecolor">
                                        <div class="color colorDel"></div>
                                        <span>删除</span>
                                    </div>
                                </div>
                            </div>
                            <el-table
                                :max-height="$store.state.tableHeight"
                                class="table"
                                ref="planTable"
                                :data="planRepairDtlList"
                                border
                                style="width: 100%"
                                @selection-change="planTableSelect"
                                :row-class-name="tableRowClass"
                                v-sortTable="{ 'tableData': planRepairDtlList, '_this': this, 'ref': 'planTable' }"
                            >
                                <el-table-column type="selection" width="55" align="center" v-if="isBatch">
                                </el-table-column>
                                <el-table-column  fixed type="index" label="序号" width="80" align="center">
                                </el-table-column>
                                <el-table-column  prop="equipmentName" label="设备名称"  min-width="200"
                                    show-overflow-tooltip align="center">
                                </el-table-column>
                                <el-table-column
                                    prop="equipmentNo"
                                    label="设备编号"
                                    min-width="200"
                                    show-overflow-tooltip
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="specificationModel"
                                    label="规格型号"
                                    min-width="150"
                                    show-overflow-tooltip
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="unit"
                                    label="计量单位"
                                    width="120"
                                    align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="changeRepairCost"
                                    width="210"
                                    align="right"
                                    label="计划维修费用（元）"
                                >
                                    <template slot="header">
                                        <div class="tab-header">变更后计划维修费用（元）<span class="tab-heade-icon">变</span></div>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="changeRepairContent"
                                    min-width="200"
                                    show-overflow-tooltip
                                    label="拟维修内容"
                                >
                                    <template slot="header">
                                        <div class="tab-header">变更后拟维修内容<span class="tab-heade-icon">变</span></div>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                    prop="repairCost"
                                    width="170"
                                    align="right"
                                    label="计划维修费用（元）"
                                >
                                </el-table-column>
                                <el-table-column
                                    prop="repairContent"
                                    min-width="200"
                                    show-overflow-tooltip
                                    label="拟维修内容"
                                >
                                </el-table-column>
                            </el-table>
                        </div>
                    </div>

                    <div id="attachCon" class="con">
                        <div class="tabs-title" id="attach">附件信息</div>
                        <attach-comp :relationId="attachId" isView bucketName="facilityplan" />
                    </div>

                    <div id="auditHistoryCon" class="con">
                        <div class="tabs-title" id="auditHistory">审核历史</div>
                        <div class="e-table">
                            <ComAuditHistoryIndex
                                billType="50151"
                                :tableData.sync="auditHistoryTable"
                                @getAuditHistory="getAuditHistory"
                                ref="AuditHistoryRef"
                            />
                        </div>
                    </div>
                </div>
            </el-tabs>
        </div>
        <div id="seat" :style="{height: seatHeight + 'px'}"></div>
        <div class="buttons">
            <ComExaButtons :auditState="auditState" :state="formData.planRepair.state" @exas="exas" :founderId="formData.planRepair.founderId" />
            <el-button size="small" @click="handleClose">取消</el-button>
        </div>
    </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
import '@/utils/jquery.scrollTo.min'
import AttachComp from '@/components/common/attachIndex'
import ComAuditHistoryIndex from '@/pages/equipment/components/auditHistory/auditHistoryIndex'
import { hideLoading, showLoading, selectDataClient } from '@/utils/common'
import request from '@/api/equip/equipPlan.js'
import requestAudit from '@/api/equip/common.js'
import count from '@/api/equip/equipPlanCount.js'
import { exas } from '@/pages/equipment/components/auditHistory/equipCom.js'
export default {
    data () {
        return {
            isBatch: false, //是否进入批量操作
            batch: '进入批量管理',
            tabsName: 'baseInfo',
            screenWidth: 0,
            screenHeight: 0,
            lastConHeight: 0,
            clickTabFlag: false, // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            formData: {
                //大修基础信息
                'planRepair': {
                    'auditTime': '',
                    'auditor': '',
                    'auditorId': '',
                    'billDate': '',
                    'billId': '',
                    'billNo': '',
                    'budgetAmount': 0,
                    'changeBillId': '',
                    'changeBillNo': '',
                    'changeBudgetAmount': 0,
                    'changeState': 0,
                    'founderId': '',
                    'founderName': '',
                    'modifier': '',
                    'modifierId': '',
                    'nullifyCreated': '',
                    'nullifyCreator': '',
                    'nullifyCreatorId': '',
                    'nullifyDescription': '',
                    'nullifyReason': '',
                    'number': 0,
                    'orgId': '',
                    'orgName': '',
                    'recorder': '',
                    'recorderId': '',
                    'remarks': '',
                    'state': 0,
                    'version': 0,
                    'workId': '',
                    'year': 0
                }
            },
            auditState: {}, //流程按钮显示状态
            auditParams: {
                'billId': this.$route.query.billid,
                'billType': 50151,  //大修计划
                'freeNextUnitIndex': null,
                'freeNextUser': '',
                'isPass': true,
                'isShareInAudit': true,
                'opinion': '',
                'orgId': '',
                'orgName': '',
                'userId': '',
                'workId': ''
            },
            nullifyParams: { //作废
                'billId': this.$route.query.billid,
                'billType': 50151,
                'nullifyCreated': '',
                'nullifyCreator': '',
                'nullifyCreatorId': '',
                'nullifyDescription': '',
                'nullifyReason': ''
            },
            billid: this.$route.query.billid,
            planSelect: [], //计划明细选择项
            planRepairDtlList: [], //计划明细表格传后端
            planRepairDtlListCopy: [], //列表显示
            changeHistoryTable: [], //变更历史
            changeHistorySelect: [], //变更历史选择项
            auditHistoryTable: [],
            currentRow: {},
            errorList: [], //控制导航栏感叹号的显示
            errorMsg: [], //计划明细错误显示
            isErrorMsg: true, //是否提醒错误信息
        }
    },
    computed: {
        ...mapState({
            timeUnitList: state => state.equip.equipData.timeUnitList //计时单位
        }),
        //当前单据状态
        state () {
            return this.formData.planRepair.state
        },
        statusLable () {
            return param=> {
                const state =  this.$store.state.equip.equipData.state
                const obj = state.find(x=>+x.value === param)
                if(obj !== undefined) {
                    return obj.label
                }
            }
        },
        attachId () {
            return this.$route.query.billid
        },
        // 填补底部空白，以使高度够滚动
        seatHeight () {
            return this.screenHeight - 72 - this.lastConHeight
        }
    },
    components: {
        AttachComp,
        ComAuditHistoryIndex,
    },
    watch: {
        //给错误标签加上提醒
        errorList: newData=>{
            const tabs = document.querySelectorAll('.el-tabs__item')
            tabs.forEach(DOM=>{
                const { childNodes } = DOM
                if(childNodes.length > 1) {
                    DOM.removeChild(childNodes[1])
                }
            })
            newData.forEach(item=>{
                const itemDom = document.querySelector(`#tab-${item}`)
                var element = document.createElement('i')
                element.className = 'el-icon-warning-outline warning'
                itemDom.appendChild(element)
            })
        },
    },
    created () {
        this.userId = localStorage.getItem('userId')
        this.getDicValue()
    },
    mounted () {
        this.init()  //初始化所有数据
        // 获取最后一个内容区域的高度，计算底部空白
        this.getLastConHeight()

        // 保存所有tabName
        const arr = ['baseInfo', 'planDetail', 'attach', 'auditHistory']
        this.tabArr = arr
        let $idsTop = []
        window.addEventListener('scroll', () => {
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            if (this.clickTabFlag) {
                return
            }

            if (!$idsTop[$idsTop.length - 1]) {
                $idsTop = arr.map(item => {
                    console.log('item', item)
                    const itemTop = document.getElementById(item).offsetTop
                    return itemTop
                })
            }
            const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
            // 倒序查找
            let curLocal = 0
            for (let len = $idsTop.length, i = len - 1; i >= 0; i--) {
                let item = $idsTop[i]
                if ((scrollTop + 1) >= item) {
                    curLocal = i
                    break
                }
            }
            // 设置对应tabName
            this.tabsName = arr[curLocal]
        })

        this.screenWidth = document.documentElement.clientWidth - this.topHeight
        this.screenHeight = document.documentElement.clientHeight - this.topHeight
        window.addEventListener('resize', () => {
            this.screenWidth = document.documentElement.clientWidth - this.topHeight
            this.screenHeight = document.documentElement.clientHeight - this.topHeight
            $idsTop = arr.map(item => {
                const itemTop = document.getElementById(item).offsetTop
                return itemTop
            })
        })
    },
    methods: {
        ...mapMutations([ 'setSelectedInfo', 'setAuditParams']),
        //获取当前使用的字典
        getDicValue () {
            this.$store.dispatch('equip/setTimeUnitList')
        },
        batchOperation () {
            this.isBatch = !this.isBatch
            if(this.isBatch) {
                this.batch = '退出批量管理'
                this.$refs.planTable.clearSelection()
            }else{
                this.batch = '进入批量管理'
            }
        },
        //初始化所有数据
        init () {
            showLoading()
            Promise.all([
                this.getInfo(),
                this.getPlanList(),
                this.getCurrentUnitInfo(),  //获取流程按钮显示状态
                this.getAuditHistory()
            ]).finally(() => {
                hideLoading()
            })
        },
        //刷新历史审核列表
        getAuditHistory () {
            requestAudit.history(this.auditParams).then(res=>{
                this.auditHistoryTable = res
            })
        },
        //获取流程按钮显示状态
        getCurrentUnitInfo () {
            requestAudit.getCurrentUnitInfo(this.auditParams).then(res => {
                this.auditState = res
            })
        },
        //基础信息查询
        getInfo () {
            request.getMajorBaseInfoChange(this.billid).then(res=>{
                this.formData.planRepair = res
            })
        },
        //计划明细查询
        getPlanList () {
            request.getChangeMajorDetails(this.billid).then(res=>{
                this.planRepairDtlList = res
                this.onUpCollect()
            })
        },
        getNowDate () {
            this.$set(
                this.formData,
                'applyTime',
                new Date()
                    .toLocaleDateString()
                    .replace(new RegExp('/', 'g'), '-')
            )
        },
        /*明细 */
        //修改行样式
        tableRowClass ({ row }) {
            if(row.state == -1) {
                return 'red'
            }else if(row.state == 1) {
                return 'green'
            }else if(row.state == 2) {
                return 'yellow'
            }
            return ''
        },
        //选择设备
        selectEquip () {
            let ids = []
            selectDataClient({
                SelectServiceToken: '/facilityplan/list/account/equipment', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: ids, // 已选中id
                Title: '选择设备' // 标题
            }).then(val => {
                this.setSelectedInfo(val)
                this.planRepairDtlList = this.planRepairDtlList ? this.planRepairDtlList : []
                val.forEach(item=>{
                    item.changeType = 1
                    let obj = {
                        'accountId': '',
                        'accountType': '',
                        'activeNo': '',
                        'billId': this.billid,
                        'billNo': '',
                        'categoryId': '',
                        'categoryName': '',
                        'changeRepairContent': '',
                        'changeRepairCost': null,
                        'changeRepairPlanDtlId': '',
                        'changeType': 1,
                        'cumulativeUsageTime': 0,
                        'equipmentId': '',
                        'equipmentName': '星球',
                        'equipmentNo': '',
                        'leasePlanId': '',
                        'manufacturer': '',
                        'mark': null,
                        'oldState': 0,
                        'oneLevelCategoryId': '',
                        'oneLevelCategoryName': '',
                        'productionNo': '',
                        'purchaseDate': '',
                        'repairContent': '',
                        'repairCost': 0,
                        'repairPlanDtlId': '',
                        'settledAmount': 0,
                        'specificationModel': '什么是快乐星球?',
                        'state': 1,
                        'unit': '',
                        ...item
                    }
                    this.planRepairDtlList.push(obj)
                })
            })
        },
        //判断当前状态是否已修改
        curStateChange (row) {
            if (row.changeRepairPlanDtlId) {
                if (row.state === 2 || row.state === -1 ) return
                if( row.changeRepairPlanDtlId == '') {
                    this.currentRow.changeType = 2
                    this.currentRow.state = 1
                }else{
                    this.currentRow.changeType = 2
                    this.currentRow.state = 2
                }
                this.currentRow = row
            }
        },
        //计划维修费用
        onAmount  () {
            this.onUpCollect()
        },
        //预算总金额 = 明细获取金额向上汇总
        onUpCollect () {
            this.formData.planRepair.changeBudgetAmount = null
            this.formData.planRepair.changeBudgetAmount = count.onMajorUpCollectChange(this.planRepairDtlList)
        },
        //获取计划明细表格的选择项
        planTableSelect (selection) {
            this.planSelect = selection
        },
        //单个删除计划明细
        handleDelete (row, $index) {
            row.oldState = row.state  //存删除之前的状态
            let length = this.errorMsg.length
            if(row.mark) {
                this.clientPop(
                    'info',
                    `${row.equipmentName}设备已被服务采购招标引用，不能删除！`,
                )
            }else{
                if(row.changeRepairPlanDtlId) {
                    this.$set(this.planRepairDtlList[$index], 'changeType', -1)
                    this.$set(this.planRepairDtlList[$index], 'state', -1)
                    if (length > 0 ) {
                        this.verifyTable()
                    }
                    this.onUpCollect()
                }else{
                    this.planRepairDtlList.splice($index, 1)
                    this.onUpCollect()
                    if (length > 0 ) {
                        this.verifyTable()
                    }
                }
            }

        },
        //点击删除弹窗
        deletePlanList () {
            const length = this.planSelect.length
            if(length > 0) {
                this.mark = this.planSelect.find(x=>{  //判断是否被引用
                    if(x.mark === true) {
                        return true
                    }
                })
            }
            if(length === 0) {
                this.clientPop(
                    'info',
                    '你还未选择数据,请选择!',
                )
            }else if(this.mark) {
                this.clientPop(
                    'info',
                    `${this.mark.equipmentName}设备已被招标/合同引用，不能删除！`,
                    this.$refs.planTable.clearSelection()
                )
            } else{
                this.clientPop(
                    'info',
                    `已选择【${length}】条数据，确定要删除吗？删除的数据可以在【回收站】还原或彻底删除。`,
                    this.delete
                )
            }
        },
        //批量删除计划明细
        delete () {
            this.existDelBeforeList()
            let length = this.errorMsg.length
            if (this.planSelect.length > 0) {
                this.planSelect.forEach(item=>{
                    if(item.changeRepairPlanDtlId) {
                        this.$set(item, 'changeType', -1)
                        this.$set(item, 'state', -1)
                        this.onUpCollect()
                        if (length > 0 ) {
                            this.verifyTable()
                        }
                        this.$refs.planTable.clearSelection()
                    }else{
                        const localArr = []
                        localArr.push(item)
                        for(let i = this.planRepairDtlList.length; i > 0; i--) {
                            for(let j = 0; j < localArr.length; j++) {
                                if(this.planRepairDtlList[i - 1] === localArr[j]) {
                                    this.planRepairDtlList.splice(i - 1, 1)
                                    this.onUpCollect()
                                    if (length > 0 ) {
                                        this.verifyTable()
                                    }
                                }
                            }
                        }
                        this.$refs.planTable.clearSelection()
                    }
                })
            }
        },
        //取消删除
        cancelDelete () {
            const length = this.planSelect.length
            if(length === 0) {
                this.clientPop(
                    'info',
                    '你还未选择删除的数据,请选择!',
                )
            }else{
                this.planSelect.forEach(item=>{
                    if(item.changeRepairPlanDtlId !== '' && item.state === -1) {
                        let obj = this.planRepairDtlList.find(x=>x.changeRepairPlanDtlId === item.changeRepairPlanDtlId)
                        obj.state = obj.oldState
                        obj.changeType = obj.oldState
                    }

                })
                this.onUpCollect()
                this.$refs.planTable.clearSelection()
            }
        },
        //存删除之前的计划明细的状态
        existDelBeforeList () {
            this.planSelect.forEach(item=>{
                let obj = this.planRepairDtlList.find(x=>x.changeRepairPlanDtlId === item.changeRepairPlanDtlId)
                obj.oldState = obj.state
            })
        },
        verifyTable () {
            return  new Promise((resolve, reject)=>{
                this.errorMsg = []
                this.planRepairDtlList.forEach((item, index)=>{
                    if(item.changeType !== -1) {
                        if(item.changeRepairCost === null || item.changeRepairCost === '') {
                            let str = `请填写第 ${index + 1} 行的（计划维修费用）`
                            this.errorMsg.push(str)
                        }
                        if( item.changeRepairContent === null || item.changeRepairContent === '') {
                            let str = `请填写第 ${index + 1} 行的（拟维修内容）`
                            this.errorMsg.push(str)
                        }
                    }
                })
                if(this.errorMsg.length > 0) {
                    this.isErrorMsg = true
                    reject()
                }else{
                    this.isErrorMsg = false
                    resolve()
                }

            })

        },
        //取消
        handleClose () {
            this.$router.replace('/majorPlanList')
        },
        //更新基本信息
        updateBaseInfo () {
            return new Promise((resolve, reject)=>{
                request.updateMajorBaseInfoChange(this.formData.planRepair).then(()=>{
                    // this.verifyTable().then(()=>{
                    //     request.updatMajorDetailChange(this.planRepairDtlList).then(()=>{
                    //         this.getInfo()
                    //         this.getPlanList()
                    //         resolve()
                    //     }).catch(err=>{
                    //         this.setError('planDetail')
                    //         reject(err)
                    //     })
                    // }).catch(err=>{
                    //     this.setError('planDetail')
                    //     reject(err)
                    // })
                    this.getInfo()
                    resolve()
                }).catch(err=>{
                    this.setError('baseInfo')
                    reject(err)
                })
            })
        },
        //更新计划明细
        updateDetailInfo () {
            return new Promise((resolve, reject)=>{
                this.verifyTable().then(()=>{
                    request.updatMajorDetailChange(this.planRepairDtlList).then(()=>{
                        this.getPlanList()
                        resolve()
                    }).catch(err=>{
                        this.setError('planDetail')
                        reject(err)
                    })
                }).catch(err=>{
                    this.setError('planDetail')
                    reject(err)
                })
            })

        },
        //保存全部数据
        saveAll () {
            //showLoading()
            this.errorList = []
            Promise.all([
                this.updateBaseInfo(),
                this.updateDetailInfo()
            ])
                .then(() => {
                    this.init()
                    this.clientPop('suc', '保存成功')
                })
                .catch(() => {
                    this.clientPop('err', '保存失败', ()=>{
                        this.scorllError()
                    })
                })
                .finally(() => {
                    hideLoading()
                })
        },
        //删除单据
        deleteBills () {
            let billids = [this.billid]
            request.majorPlanDelete(billids).then(()=>{
                this.clientPop('suc', '删除成功', this.handleClose)
            })
        },
        // 审核相关操作
        async exas (arg) {
            const requestFn = ()=>{
                return []
            }
            exas(arg, this, requestFn, 0)
        },
        // 获取最后一个内容区域的高度，计算底部空白
        getLastConHeight () {
            let si = setInterval(() => {
                // 因为dom异步加载，通过轮询找到渲染后的dom，获取高度
                if (document.getElementById('recodesCon')) {
                    const lastConHeight = document.getElementById('recodesCon').offsetHeight
                    console.log('lastConHeight: ', lastConHeight)
                    this.lastConHeight = lastConHeight
                    clearInterval(si)
                    si = null
                }
            }, 100)
        },
        onChangeTab (e) {
            const height  = $('#' + e.name).offset().top
            $.scrollTo(height - this.topHeight, 500)
            // 如果手动点击时，则不做滚动事件逻辑，只有滚动屏幕时才走滚动事件逻辑
            this.clickTabFlag = true
            // 动画结束后，恢复状态
            setTimeout(() => {
                this.clickTabFlag = false
            }, 600)
        },
        //设置错误标签
        setError (name) {
            if(!this.errorList.find(x=>x === name)) {
                this.errorList.push(name)
            }
        },
        //跳转到第一个错误标签
        scorllError () {
            let num = this.tabArr.length
            this.errorList.forEach(item=>{
                let index = this.tabArr.findIndex(x=>x === item)
                num = index < num ? index : num
            })
            const obj = { name: this.tabArr[num] }
            this.tabsName = this.tabArr[num]
            this.onChangeTab(obj)
        },
    }
}
</script>

<style lang="scss" scoped>
.e-table {
    background: #fff;
}
</style>
